package com.jthinking.test.deserializer;

import com.google.protobuf.InvalidProtocolBufferException;
import com.jthinking.test.proto.ImageProto;
import org.apache.kafka.common.serialization.Deserializer;

import java.util.Map;

public class ImageProtobufDeserializer implements Deserializer<ImageProto.Image> {

    @Override
    public void configure(Map<String, ?> configs, boolean isKey) {

    }

    @Override
    public ImageProto.Image deserialize(String topic, byte[] data) {
        ImageProto.Image image = null;
        try {
            image = ImageProto.Image.parseFrom(data);
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
        }
        return image;
    }

    @Override
    public void close() {

    }
}
